module SecretAccessible
  extend ActiveSupport::Concern


  def generate_secret
    secrets = self.class.all.map { | instance | instance.secret }
    secret  = next_secret
    secret  = next_secret while (secrets.include? secret)
    secret
  end

  def next_secret ; SecureRandom.hex N_SECERT_BYTES ; end ;
end
